iconhelper: Remove the context argument
authorBenjamin Otte <otte@redhat.com>
Tue, 8 Dec 2015 19:57:24 +0000 (20:57 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 9 Dec 2015 12:30:40 +0000 (13:30 +0100)
Instead, use the widget's context.

gtk/deprecated/gtkstatusicon.c
gtk/gtkcellrendererpixbuf.c
gtk/gtkentry.c
gtk/gtkiconhelper.c
gtk/gtkiconhelperprivate.h
gtk/gtkimage.c
gtk/gtkspinbutton.c

index fd65b0aa5439b06747cbfe510182e54657e6fb9e..b46dfcc7a98b579b2ddf044ad9c545b1c91acf84 100644 (file)
@@ -1376,7 +1376,6 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
   HICON prev_hicon;
 #endif
   GtkIconHelper *icon_helper;
-  GtkStyleContext *context;
   cairo_surface_t *surface;
   GtkWidget *widget;
   GdkPixbuf *pixbuf;
@@ -1391,7 +1390,6 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
   if (widget == NULL)
     return;
 
-  context = gtk_widget_get_style_context (widget);
   round_size = round_pixel_size (widget, priv->size);
 
   icon_helper = _gtk_icon_helper_new (widget);
@@ -1399,7 +1397,7 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
   _gtk_icon_helper_set_definition (icon_helper, priv->image_def);
   _gtk_icon_helper_set_icon_size (icon_helper, GTK_ICON_SIZE_SMALL_TOOLBAR);
   _gtk_icon_helper_set_pixel_size (icon_helper, round_size);
-  surface = gtk_icon_helper_load_surface (icon_helper, context, 1);
+  surface = gtk_icon_helper_load_surface (icon_helper, 1);
   pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, round_size, round_size);
   cairo_surface_destroy (surface);
 
index 2f781cbbf4e30cc53bd5b043d1cd2e9be44e4e20..36dbb045b7c7e0e04949ba64b43b82d72b75aef8 100644 (file)
@@ -480,7 +480,6 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer    *cell,
 
   if (!_gtk_icon_helper_get_is_empty (icon_helper))
     _gtk_icon_helper_get_size (icon_helper, 
-                               gtk_widget_get_style_context (widget),
                                &pixbuf_width, &pixbuf_height);
 
   g_object_unref (icon_helper);
@@ -594,7 +593,7 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer      *cell,
     icon_helper = create_icon_helper (cellpixbuf, widget);
 
   _gtk_icon_helper_draw (icon_helper,
-                         context, cr,
+                         cr,
                          pix_rect.x, pix_rect.y);
   g_object_unref (icon_helper);
 
index 83e738b71f877c58505b7b8b4d8d7ccefe42b1e2..31f0effbc5610f67bdf726525c24e44bdddbd891 100644 (file)
@@ -2785,7 +2785,7 @@ get_icon_width (GtkEntry             *entry,
   state = gtk_style_context_get_state (context);
   gtk_style_context_get_padding (context, state, &padding);
 
-  _gtk_icon_helper_get_size (icon_info->icon_helper, context,
+  _gtk_icon_helper_get_size (icon_info->icon_helper,
                              &width, NULL);
   gtk_style_context_restore (context);
 
@@ -3795,7 +3795,7 @@ draw_icon (GtkWidget            *widget,
 
   context = gtk_widget_get_style_context (widget);
   gtk_style_context_save_to_node (context, icon_info->css_node);
-  _gtk_icon_helper_get_size (icon_info->icon_helper, context,
+  _gtk_icon_helper_get_size (icon_info->icon_helper,
                              &pix_width, &pix_height);
   state = gtk_style_context_get_state (context);
   gtk_style_context_get_padding (context, state, &padding);
@@ -3804,7 +3804,7 @@ draw_icon (GtkWidget            *widget,
   y = MAX (0, (height - pix_height) / 2);
 
   _gtk_icon_helper_draw (icon_info->icon_helper,
-                         context, cr,
+                         cr,
                          x, y);
 
   gtk_style_context_restore (context);
@@ -8868,10 +8868,8 @@ gtk_entry_get_icon_pixbuf (GtkEntry             *entry,
   context = gtk_widget_get_style_context (GTK_WIDGET (entry));
   gtk_style_context_save_to_node (context, icon_info->css_node);
 
-  _gtk_icon_helper_get_size (icon_info->icon_helper, context, &width, &height);
-  surface = gtk_icon_helper_load_surface (icon_info->icon_helper,
-                                          context,
-                                          1);
+  _gtk_icon_helper_get_size (icon_info->icon_helper, &width, &height);
+  surface = gtk_icon_helper_load_surface (icon_info->icon_helper, 1);
 
   pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
 
index ad79e2d85e25baabdac82c94e3df6d2eecdb2d27..a8f6698118d513f4fc330c76d34335c1a91cedd8 100644 (file)
@@ -428,13 +428,15 @@ ensure_surface_for_gicon (GtkIconHelper    *self,
 
 cairo_surface_t *
 gtk_icon_helper_load_surface (GtkIconHelper   *self,
-                              GtkStyleContext *context,
                               int              scale)
 {
   cairo_surface_t *surface;
+  GtkStyleContext *context;
   GtkIconSet *icon_set;
   GIcon *gicon;
 
+  context = gtk_widget_get_style_context (self->priv->owner);
+
   switch (gtk_image_definition_get_storage_type (self->priv->def))
     {
     case GTK_IMAGE_SURFACE:
@@ -519,17 +521,18 @@ gtk_icon_helper_ensure_surface (GtkIconHelper   *self,
 
   scale = gtk_widget_get_scale_factor (self->priv->owner);
 
-  self->priv->rendered_surface = gtk_icon_helper_load_surface (self, context, scale);
+  self->priv->rendered_surface = gtk_icon_helper_load_surface (self, scale);
 }
 
 void
 _gtk_icon_helper_get_size (GtkIconHelper *self,
-                           GtkStyleContext *context,
                            gint *width_out,
                            gint *height_out)
 {
+  GtkStyleContext *context;
   gint width, height, scale;
 
+  context = gtk_widget_get_style_context (self->priv->owner);
   width = height = 0;
 
   /* Certain kinds of images are easy to calculate the size for, these
@@ -791,11 +794,12 @@ _gtk_icon_helper_new (GtkWidget *owner)
 
 void
 _gtk_icon_helper_draw (GtkIconHelper *self,
-                       GtkStyleContext *context,
                        cairo_t *cr,
                        gdouble x,
                        gdouble y)
 {
+  GtkStyleContext *context = gtk_widget_get_style_context (self->priv->owner);
+
   gtk_icon_helper_ensure_surface (self, context);
 
   if (self->priv->rendered_surface != NULL)
index df4fb6ab77d765da229c6320a7d254fc0a2c018f..4fcbd8d111568a524ba75c196509fd0cec7c6de6 100644 (file)
@@ -121,15 +121,12 @@ const gchar *_gtk_icon_helper_get_stock_id (GtkIconHelper *self);
 const gchar *_gtk_icon_helper_get_icon_name (GtkIconHelper *self);
 
 cairo_surface_t *gtk_icon_helper_load_surface (GtkIconHelper *self,
-                                              GtkStyleContext *context,
                                                int              scale);
 void _gtk_icon_helper_get_size (GtkIconHelper *self,
-                                GtkStyleContext *context,
                                 gint *width_out,
                                 gint *height_out);
 
 void _gtk_icon_helper_draw (GtkIconHelper *self,
-                            GtkStyleContext *context,
                             cairo_t *cr,
                             gdouble x,
                             gdouble y);
index 48c00dc3e503ac01ebfb751940468e170a68d491..7494f413d7348bd27a4b0a5b7ab91c5c36ede073 100644 (file)
@@ -1623,10 +1623,8 @@ gtk_image_get_preferred_size (GtkImage *image,
   GtkImagePrivate *priv = image->priv;
   gint width, height;
   GtkBorder border;
-  GtkStyleContext *context;
 
-  context = gtk_widget_get_style_context (GTK_WIDGET (image));
-  _gtk_icon_helper_get_size (priv->icon_helper, context, &width, &height);
+  _gtk_icon_helper_get_size (priv->icon_helper, &width, &height);
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   _gtk_misc_get_padding_and_border (GTK_MISC (image), &border);
 G_GNUC_END_IGNORE_DEPRECATIONS
@@ -1716,7 +1714,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   else
     {
       _gtk_icon_helper_draw (priv->icon_helper, 
-                             context, cr,
+                             cr,
                              x, y);
     }
 
index 7b2f2984da2bcf29f713b30a8e77e24df2535798..27f60d3b6a0eb6df70809a558ce6e5621c0d25a3 100644 (file)
@@ -1113,7 +1113,7 @@ gtk_spin_button_panel_draw (GtkSpinButton   *spin_button,
       _gtk_icon_helper_set_icon_name (icon_helper, "list-add-symbolic", GTK_ICON_SIZE_MENU);
     }
 
-  _gtk_icon_helper_get_size (icon_helper, context, &icon_width, &icon_height);
+  _gtk_icon_helper_get_size (icon_helper, &icon_width, &icon_height);
 
   gtk_render_background (context, cr, 0, 0, width, height);
   gtk_render_frame (context, cr, 0, 0, width, height);
@@ -1121,7 +1121,7 @@ gtk_spin_button_panel_draw (GtkSpinButton   *spin_button,
   x = floor ((width - icon_width) / 2.0);
   y = floor ((height - icon_height) / 2.0);
 
-  _gtk_icon_helper_draw (icon_helper, context, cr, x, y);
+  _gtk_icon_helper_draw (icon_helper, cr, x, y);
   cairo_restore (cr);
 
   gtk_style_context_restore (context);